import 'package:flutter/material.dart';

import '../../config/color_config.dart';
import '../../config/string_config.dart';
import '../../utils/screen_util.dart';

class TipDialog extends StatelessWidget {
  const TipDialog({
    super.key,
    required this.title,
    required this.message,
    this.onCancel,
    this.onConfirm,
  });

  final String title;
  final String message;
  final VoidCallback? onCancel;
  final VoidCallback? onConfirm;

  @override
  Widget build(BuildContext context) {
    return Dialog(
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(14),
      ),
      child: Container(
        width: double.infinity,
        padding: EdgeInsets.fromLTRB(ScreenUtil.setWidth(24), 0, ScreenUtil.setWidth(24), 0),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(14),
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            const SizedBox(height: 20),
            Text(
              title,
              style: const TextStyle(
                fontSize: 17,
                fontWeight: FontWeight.w600,
                color: Colors.black,
              ),
            ),
            const SizedBox(height: 8),
            Text(
              message,
              textAlign: TextAlign.center,
              style: const TextStyle(
                fontSize: 13,
                color: ColorConfig.dialogDescriptionColor,
                height: 1.3,
              ),
            ),
            const SizedBox(height: 16),
            Container(
              decoration: const BoxDecoration(
                border: Border(
                  top: BorderSide(
                    color: ColorConfig.dialogBorderColor,
                    width: 0.5,
                  ),
                ),
              ),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  Expanded(
                    child: InkWell(
                      onTap: () {
                        Navigator.of(context).pop();
                        onCancel?.call();
                      },
                      child: Container(
                        height: 44,
                        alignment: Alignment.center,
                        decoration: const BoxDecoration(
                          border: Border(
                            right: BorderSide(
                              color: ColorConfig.dialogBorderColor,
                              width: 0.5,
                            ),
                          ),
                        ),
                        child: const Text(
                          StringConfig.tip_dialog_cancel,
                          style: TextStyle(
                            color: ColorConfig.dialogButtonColor,
                            fontSize: 17,
                            fontWeight: FontWeight.w400,
                          ),
                        ),
                      ),
                    ),
                  ),
                  Expanded(
                    child: InkWell(
                      onTap: () {
                        Navigator.of(context).pop();
                        onConfirm?.call();
                      },
                      child: Container(
                        height: 44,
                        alignment: Alignment.center,
                        child: const Text(
                          StringConfig.tip_dialog_confirm,
                          style: TextStyle(
                            color: ColorConfig.dialogButtonColor,
                            fontSize: 17,
                            fontWeight: FontWeight.w600,
                          ),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
